package com.xhwl.data.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhwl.common.dto.cent.sdata.AccountDTO;
import com.xhwl.common.dto.cent.sdata.AccountDetailDTO;
import com.xhwl.common.dto.cent.sdata.GroupAccountDTO;
import com.xhwl.common.pojo.cent.sdata.Account;
import com.xhwl.common.query.cent.sdata.AccountQuery;
import com.xhwl.common.query.cent.sdata.AccountRoleQuery;
import com.xhwl.common.query.cent.sdata.GroupAccountQuery;
import com.xhwl.common.vo.cent.sdata.AccountCriteria;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * @description: 账户
 * @author:
 * @create: 2020-11-25
 **/
@Repository
public interface IAccountDao extends BaseMapper<Account> {

    Page<GroupAccountDTO> getGroupAccountDynamic(Page page, @Param("groupAccountQuery") GroupAccountQuery groupAccountQuery);

    Page<AccountDTO> getPageListWithAuth(Page page, @Param("accountQuery") AccountQuery accountQuery);

    List<AccountDTO> getListWithAuth(@Param("accountQuery") AccountQuery accountQuery);

    /**
     * 根据企业id查找 账号、企业关联的信息
     *
     * @param enterpriseIdList
     * @param accountIdList
     * @return
     */
    List<AccountDetailDTO> getAccountEnterpriseInfoByIdList(@Param("enterpriseIdList") List<Integer> enterpriseIdList, @Param("accountIdList") List<Integer> accountIdList);

    /**
     * 根据账号id、角色id查找 账号、角色关联的信息
     *
     * @param accountIdList
     * @param roleIdList
     * @return
     */
    @Deprecated
    List<AccountDetailDTO> getAccountRoleInfoByIdList(@Param("accountIdList") List<Integer> accountIdList, @Param("roleIdList") List<Integer> roleIdList);




    /**
     * 动态查找 账号、角色关联的信息
     *
     * @param accountRoleQuery
     * @return
     */
    List<AccountDetailDTO> getAccountRoleDynamic( @Param("accountRoleQuery") AccountRoleQuery accountRoleQuery);

    /**
     * 根据账号id、角色id 分页查找 账号、角色关联的信息 （分页）
     *
     * @param page
     * @param accountIdList
     * @param roleIdList
     * @return
     */

    Page<AccountDetailDTO> getPageAccountRoleInfoByIdList(Page page, @Param("accountIdList") List<Integer> accountIdList, @Param("roleIdList") List<Integer> roleIdList);


    /**
     * 根据账号id查找 账号、项目关联的信息
     *
     * @param accountIdList
     * @return
     */
    List<AccountDetailDTO> getAccountProjectInfoByIdList(@Param("accountIdList") List<Integer> accountIdList);

    List<AccountDetailDTO> getListByProAndRole(@Param("projectId") Integer projectId, @Param("roleIdList") List<Integer> roleIdList);


    /**
     * 动态查找 超管、企管、项管
     *
     * @param roleType
     * @param roleGrade
     * @param accountIdList
     * @return
     */
    List<Integer> getAdminAccountDynamic(@Param("roleType") Integer roleType, @Param("roleGrade") Short roleGrade, @Param("accountIdList") List<Integer> accountIdList);

    Page<Account> page(Page page, @Param("accountCriteria") AccountCriteria accountCriteria);

    /**
     * 复杂条件的分页查询
     * @param page
     * @param accountQuery
     * @return
     */
    Page<AccountDTO> complexPage(Page page, @Param("accountQuery")AccountQuery accountQuery);
}
